// Author: Domien Nowicki

#ifndef MAPPROVINCEITEM_H
#define MAPPROVINCEITEM_H

#include <QWidget>
#include <QGraphicsItem>
#include "Province.h"
#include "MapPointItem.h"

class MapWidget;

class MapProvinceItem : public QObject, public QGraphicsItem, public Province
{
	Q_OBJECT
public:
	// Constructors
	MapProvinceItem(MapWidget *mapView, const std::string& name);
	MapProvinceItem(const MapProvinceItem& rhs);
	MapProvinceItem(MapWidget *mapView, const Province& rhs);

	// Destructors
	virtual ~MapProvinceItem();

	// Overloaded operations
	virtual Point* InsertNewPoint(int x, int y);
	virtual Point* InsertNewPoint(const Point& point);
	virtual void SetColor(Color newColor);
	virtual void SetName(const std::string& name);


	// Qt overloaded functions
	const QPolygon& GetPolygon() const;
	QRectF boundingRect() const;
	QPainterPath shape() const;
	void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
	void mousePressEvent(QGraphicsSceneMouseEvent *e);

signals:
	// Signal for when a parent was added to a scene
	void parentAddedToScene(QGraphicsScene*);

public slots:
	// Add item to the graphics scene
	void AddToScene(QGraphicsScene *scene, QGraphicsItem *item=0);
	// Set all province's cursor
	void SetCursor(const QCursor& cursor);

	
protected:
	// Overloaded operation
	virtual Point* InsertPoint(MapPointItem *item);

signals:
	void clickedProvince(Province*);
private:
	MapWidget *map;
	QRectF bounds;
	QPolygon poly;
	QPainterPath path;

	static const unsigned int PROVINCEADJUST = 10;
	static const unsigned int PROVINCEZ = 2;
};

#endif /*MAPPROVINCEITEM_H*/
